<%@ page import="java.sql.ResultSet" %>
<%@ include file="connect.jsp" %>
<%--
  Created by IntelliJ IDEA.
  User: Calvin
  Date: 12/1/12
  Time: 7:42 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <script type="text/javascript">
        function validasi() {
            var nama = document.getElementById("gamesName").value;
            var sound = document.getElementById("sound").value;

            if (nama == null || nama == "") {
                err.innerHTML = "Please insert case's name!";
                return false;

            }
            else if (sound == null || sound == "") {
                err.innerHTML = "Please insert the sound's name!";
                return false;
            }
            else if (sound.indexOf(" ") >= 1) {
                err.innerHTML = "Sound's name can't contain spaces!";
                return false;
            }
            else {
                return true;
            }
        }

    </script>
</head>
<body>
<div id="popup-header">
    <h2>Add New Case</h2>
</div>
<form action="saveNewCase.jsp" onsubmit="return validasi()">
    <table id="word1">
        <div class="txt-fld">
            <tr>
                <td>Choose Category</td>
                <td>:</td>
                <td><select style="margin-top: 10px;  font-family: Segoe UI; font-size: 12pt " name="category">

                    <%
                        ResultSet rs = stat.executeQuery("Select * from categories order by categoryID asc");
                        while (rs.next()) {
                            String kategori = rs.getString("categoryName");
                            String idKategori = rs.getString("categoryID");
                    %>

                    <option value="<%=idKategori%>"><%=kategori%>
                    </option>
                    <%}%>
                </select></td>
            </tr>
            <tr>
                <td>Case Name</td>
                <td>:</td>
                <td><input type="text" name="gamesName" id="gamesName"></td>
            </tr>

            <tr>
                <td>Sound Name</td>
                <td>:</td>
                <td><input type="text" name="sound" id="sound"></td>

            </tr>
            <tr>
                <td colspan="3" style="color: red; font-weight: 800">*Please make sure the file is on the directory
                </td>
            </tr>
        </div>
        <tr>
            <td colspan="3">
                <div id="err">
                </div>
            </td>
        </tr>
        <tr align="right">
            <td colspan="3">
                <div class="btn-fld">
                    <button type="submit">Save</button>
                </div>
            </td>
        </tr>


    </table>
</form>

</body>
</html>